<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>信达登录页面</title>
    <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
    <meta name="author" content="Vincent Garreau" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <style type="text/css">
        /*Reset*/
        * {
            box-sizing: content-box;
        }

        a:hover,
        a:focus {
            text-decoration: none;
        }

        body,
        div,
        dl,
        dt,
        dd,
        ul,
        ol,
        li,
        h1,
        h2,
        h3,
        h4,
        h5,
        h6,
        pre,
        form,
        fieldset,
        input,
        textarea,
        p,
        blockquote,
        th,
        td {
            margin: 0;
            padding: 0;
        }

        table {
            border-collapse: collapse;
            border-spacing: 0;
        }

        body {
            -webkit-text-size-adjust: none;
        }

        fieldset,
        img {
            border: 0;
        }

        img {
            vertical-align: top;
            max-width: 100%;
        }

        address,
        caption,
        cite,
        code,
        dfn,
        em,
        th,
        var {
            font-style: normal;
            font-weight: normal;
        }

        ol,
        ul {
            list-style: none;
        }

        caption,
        th {
            text-align: left;
        }

        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
            font-size: 100%;
            font-weight: normal;
        }

        q:before,
        q:after {
            content: '';
        }

        abbr,
        acronym {
            border: 0;
        }

        .clearfix:after {
            visibility: hidden;
            display: block;
            font-size: 0;
            content: " ";
            clear: both;
            height: 0;
        }

        * html .clearfix {
            zoom: 1;
        }

        /* IE6 */
        *:first-child+html .clearfix {
            zoom: 1;
        }

        /* IE7 */
        .cli {
            clear: both;
            font-size: 0;
            height: 0;
            overflow: hidden;
            display: block;
        }

        .lclear {
            clear: left;
            font-size: 0;
            height: 0;
            overflow: hidden;
        }

        .fl {
            float: left;
        }

        .fr {
            float: right;
        }

        /* ֹ
iframe{nifm2:expression(this.src='about:blank',this.outerHTML='');}
script{no2js:expression((this.src.toLowerCase().indexOf('http')==0)?document.close():'');}
*/
        /* ıԼ˶
div{word-wrap: break-word;word-break: normal;}  
p{text-align:justify; text-justify:inter-ideograph;}
*/
        /*general*/
        body {
            font-size: 12px;
            font-family: '微软雅黑', "宋体", "Arial Narrow", Helvetica, sans-serif;
            color: #000;
            line-height: 1.2;
            text-align: left;
        }

        a {
            color: #333;
            text-decoration: none;
        }



        html,
        body {
            width: 100%;
            height: 100%;
        }

        canvas {
            display: block;
            vertical-align: bottom;
        }

        .count-particles {
            background: #000022;
            position: absolute;
            top: 48px;
            left: 0;
            width: 80px;
            color: #13E8E9;
            font-size: .8em;
            text-align: left;
            text-indent: 4px;
            line-height: 14px;
            padding-bottom: 2px;
            font-family: Helvetica, Arial, sans-serif;
            font-weight: bold;
        }

        .js-count-particles {
            font-size: 1.1em;
        }

        #stats,
        .count-particles {
            -webkit-user-select: none;
            margin-top: 5px;
            margin-left: 5px;
        }

        #stats {
            border-radius: 3px 3px 0 0;
            overflow: hidden;
        }

        .count-particles {
            border-radius: 0 0 3px 3px;
        }


        #particles-js {
            width: 100%;
            height: 100%;
            position: relative;
            background-image: url(img/login_bg.png);
            background-position: 50% 50%;
            background-size: cover;
            background-repeat: no-repeat;
            margin-left: auto;
            margin-right: auto;
        }

        .sk-rotating-plane {
            display: none;
            width: 80px;
            height: 80px;
            margin: auto;
            background-color: white;
            -webkit-animation: sk-rotating-plane 1.2s infinite ease-in-out;
            animation: sk-rotating-plane 1.2s infinite ease-in-out;
            z-index: 1;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -40px;
            margin-top: -80px;
        }

        .sk-rotating-plane.active {
            display: block;
        }

        @keyframes sk-rotating-plane {
            0% {
                -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
                transform: perspective(120px) rotateX(0deg) rotateY(0deg);
            }

            50% {
                -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
                transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
            }

            100% {
                -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
                transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
            }
        }

        @keyframes login-small {
            0% {
                transform: scale(1);
                -moz-transform: scale(1);
                /* Firefox 4 */
                -webkit-transform: scale(1);
                /* Safari 和 Chrome */
                -o-transform: scale(1);
                /* Opera */
                -ms-transform: scale(1);
                /* IE 9 */
            }

            100% {
                transform: scale(0.2);
                -moz-transform: scale(0.1);
                /* Firefox 4 */
                -webkit-transform: scale(0.2);
                /* Safari 和 Chrome */
                -o-transform: scale(0.1);
                /* Opera */
                -ms-transform: scale(0.1);
                /* IE 9 */
            }
        }

        .login {
            z-index: 2;
            position: absolute;
            width: 350px;
            border-radius: 5px;
            height: 460px;
            background: rgba(255, 255, 255, .7);
            box-shadow: 0px 0px 5px #333333;
            top: 50%;
            left: 50%;
            margin-top: -250px;
            margin-left: -175px;
            transition: all 1s;
            -moz-transition: all 1s;
            /* Firefox 4 */
            -webkit-transition: all 1s;
            /* Safari 和 Chrome */
            -o-transition: all 1s;
            /* Opera */
        }

        .login-top {
            font-size: 20px;
            margin-top: 10px;
            box-sizing: border-box;
            color: #333333;
            margin-bottom: 50px;
            text-align: center;
        }

        .login-center {
            width: 100%;
            box-sizing: border-box;
            padding: 0 40px;
            margin-bottom: 30px;
        }

        .login-center-img {
            width: 20px;
            height: 20px;
            float: left;
            margin-top: 5px;
        }

        .login-center-img>img {
            width: 100%;
        }

        .login-center-input {
            float: left;
            width: 230px;
            margin-left: 15px;
            height: 30px;
            position: relative;
        }

        .login-center-input input {
            z-index: 2;
            transition: all 0.5s;
            padding-left: 10px;
            color: #333333;
            width: 100%;
            height: 30px;
            border: 0;
            border-bottom: 1px solid #cccccc;
            border-top: 1px solid #ffffff;
            border-left: 1px solid #ffffff;
            border-right: 1px solid #ffffff;
            box-sizing: border-box;
            outline: none;
            position: relative;
        }

        .login-center-input input:focus {
            border: 1px solid dodgerblue;
        }

        .login-center-input-text {
            background: white;
            padding: 0 5px;
            position: absolute;
            z-index: 0;
            opacity: 0;
            height: 20px;
            top: 50%;
            margin-top: -10px;
            font-size: 14px;
            left: 5px;
            color: dodgerblue;
            line-height: 20px;
            transition: all 0.5s;
            -moz-transition: all 0.5s;
            /* Firefox 4 */
            -webkit-transition: all 0.5s;
            /* Safari 和 Chrome */
            -o-transition: all 0.5s;
            /* Opera */
        }

        .login-center-input input:focus~.login-center-input-text {
            top: 0;
            z-index: 3;
            opacity: 1;
            margin-top: -15px;
        }

        .login.active {
            -webkit-animation: login-small 0.8s;
            animation: login-small 0.8s;
            animation-fill-mode: forwards;
            -webkit-animation-fill-mode: forwards
        }

        .login-button {
            cursor: pointer;
            width: 250px;
            text-align: center;
            height: 40px;
            line-height: 40px;
            background-color: dodgerblue;
            border-radius: 5px;
            margin: 0 auto;
            margin-top: 50px;
            color: white;
        }

        .form-control {
            width: 100%;
            height: 30px;
        }
    </style>
</head>

<body>
    <div id="particles-js">
        <div class="login">
            <div style="text-align: center">

            </div>
            <div class="login-top">
                <div>
                    <span><img src="img/logo.png" alt="" style="width:50px;margin-top: 30px;margin-right: 10px;"></span>
                    <span style="margin-top: 40px;display:inline-block">信达平台资源管理系统</span>
                </div>
            </div>
            <form method="get" action="index.html" class="form">
                <div class="login-center clearfix">
                    <div class="login-center-img"><img src="img/name.png" /></div>
                    <div class="login-center-input">
                        <input type="text" name="loginname" value="" placeholder="请输入您的用户名"
                            onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'" />
                        <div class="login-center-input-text">用户名</div>
                    </div>
                </div>
                <div class="login-center clearfix">
                    <div class="login-center-img"><img src="img/password.png" /></div>
                    <div class="login-center-input">
                        <input type="password" class="passwordM" name="password" value="" placeholder="请输入您的密码"
                            onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'" minlength="8" />
                        <div class="login-center-input-text">密码</div>
                    </div>
                </div>
                <div class="login-center clearfix">
                    <div class="login-center-img"><img src="img/users.png" /></div>
                    <div class="login-center-input">
                        <select class="form-control" name="roletype">
                            <option value="1">使用者</option>
                            <option value="2">管理员</option>
                        </select>
                        <div class="login-center-input-text">用户角色</div>
                    </div>
                </div>
            </form>
            <div class="login-button">
                登录
            </div>
        </div>
        <div class="sk-rotating-plane"></div>
    </div>
    <!-- scripts -->
    <script src="js/jquery.min.js"></script>
    <!-- 自定义js -->
    <script src="js/particles.min.js"></script>
    <script src="js/app.js"></script>
    <script src="js/plugins/sweetalert/sweetalert.min.js"></script>

    <script type="text/javascript">
        // 服务端IP地址
        function getUrl() {
            return "http://192.168.31.67:8080/ypt"
        }


        $(".login-button").on('click', function (event) {

            // if ($(".passwordM").val().length<8) 
            //     {
            //             swal({
            //                 title: "登录失败",
            //                 text: "密码请至少设置8位",
            //                 type: "warning"
            //             })
            //     }


            var formData = $(".form").serialize();
            $.ajax({
                url: getUrl() + '/login',
                // url: 'https://easy-mock.com/mock/5b4db19e461ecb1842d1dc3c/index/register',
                type: 'GET',
                dataType: 'jsonp',
                data: formData,
                success: function (response) {
                    console.log(response)
                    if (response.status == 200) {
                        var user_id = response.data.user.uSERID //id用户  1使用者   2管理员
                        var rE_NAME = response.data.user.rE_NAME //用户名称
                        console.log(user_id)
                        var isMultiRoles = response.data.isMultiRoles // 是否有多个角色 1 有  0 无
                        localStorage.setItem("user_id", user_id)
                        localStorage.setItem("rE_NAME", rE_NAME)
                        // localStorage.setItem("isMultiRoles", isMultiRoles)  //

                        if (response.data.roletype == 1) {
                            // 使用者
                            localStorage.setItem('user_role', "用户")
                            // window.location.href = "index.html"
                        } else if (response.data.roletype == 2) {
                            // 去管理员页面
                            localStorage.setItem('user_role', "管理员")
                            window.location.href = "index.html"
                        }
                    } else if (response.status == 500) {
                        // 登录失败
                        swal({
                            title: "登录失败",
                            text: "用户不存在或密码错误",
                            type: "warning"
                        })


                    }
                }
            })

        })



                // function hasClass(elem, cls) {
                //   cls = cls || '';
                //   if (cls.replace(/\s/g, '').length == 0) return false; //当cls没有参数时，返回false
                //   return new RegExp(' ' + cls + ' ').test(' ' + elem.className + ' ');
                // }

                // function addClass(ele, cls) {
                //   if (!hasClass(ele, cls)) {
                //     ele.className = ele.className == '' ? cls : ele.className + ' ' + cls;
                //   }
                // }

                // function removeClass(ele, cls) {
                //   if (hasClass(ele, cls)) {
                //     var newClass = ' ' + ele.className.replace(/[\t\r\n]/g, '') + ' ';
                //     while (newClass.indexOf(' ' + cls + ' ') >= 0) {
                //       newClass = newClass.replace(' ' + cls + ' ', ' ');
                //     }
                //     ele.className = newClass.replace(/^\s+|\s+$/g, '');
                //   }
                // }
                //  document.querySelector(".login-button").onclick = function(){
                //          addClass(document.querySelector(".login"), "active")
                //          setTimeout(function(){
                //              addClass(document.querySelector(".sk-rotating-plane"), "active")
                //              document.querySelector(".login").style.display = "none"
                //          },800)
                //          setTimeout(function(){
                //              removeClass(document.querySelector(".login"), "active")
                //              removeClass(document.querySelector(".sk-rotating-plane"), "active")
                //              document.querySelector(".login").style.display = "block"
                //              alert("登录成功")

                //          },3000)
                //  }
    </script>
</body>

</html>